import aImgLocal from '@/components/a-img-local.vue'
import aImgQn from '@/components/a-img-local.vue'
import config from '@/common/config.js'
export default function (spaceValue,callBack = () => {}) {

	const pickImg = reactive({
		spaceValue:spaceValue,//空间名称
		showQn: false,//是否显示七牛云图片选择弹窗
		showLocal: false,//是否显示服务器图片选择弹窗
		name: '',//需要选择图片的字段
		serverImg:spaceValue == 'local'?config.serverImg:config.serverImg,//图片拼接域名
	});
	
	//选择图片
	const selectImg = (name)=>{
		if(pickImg.spaceValue == 'local'){
			pickImg.showLocal = true;
		}else{
			pickImg.showQn = true;
		}
		pickImg.name = name;
	}
	
	//确定图片
	const imgSuccess = (res) => {
		pickImg.showQn = false;
		pickImg.showLocal = false;
		typeof(callBack)==="function"&&callBack(res)
	}
	
    return {
		aImgLocal,
		aImgQn,
		pickImg,
		selectImg,
		imgSuccess
    }
}